class SettingController < ApplicationController
layout "admin"
before_filter :login_required
before_filter :initvars
after_filter :config_mailer, :only => [:create,:update]

  def index
    redirect_to :controller => "setting", :action => "show", :id=>1
  end

  def list
    redirect_to :controller => "setting", :action => "show", :id=>1
  end

  def show
    @setting = Setting.find(params[:id])
  end

  def new
    @setting = Setting.new
  end

  def create
    @setting = Setting.new(params[:setting])
    if @setting.save
      flash[:notice] = 'Settings successfully created.'
      redirect_to :action => 'list'
    else
      render :action => 'new'
    end
  end

  def edit
    @themes =Dir.entries(RAILS_ROOT+"/themes")
    @setting = Setting.find(params[:id])
  end

  def update
    @setting = Setting.find(params[:id])
    if @setting.update_attributes(params[:setting])
      session[:loadedsettings]=nil
      flash[:notice] = 'Settings successfully updated.'
      redirect_to :action => 'show', :id => @setting
    else
      render :action => 'edit'
    end
  end

  def destroy
    Setting.find(params[:id]).destroy
    redirect_to :action => 'list'
  end
end
